package com.study.hospital_3.controller;

import com.study.hospital_3.service.UserService;
import com.study.hospital_3.vo.UserUpdateVO;
import com.study.hospital_3.vo.UserVO;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/selectUsers")
    public Map<String, Object> selectUsers(UserVO userVO) {
        return userService.selectUsers(userVO);
    }

    @PostMapping("/insert")
    public Map<String, Object> insert(@RequestBody UserVO userVO) {
        return userService.insert(userVO);
    }

    @PostMapping("/login")
    public Map<String, Object> login(@RequestBody UserVO userVO) {
        return userService.login(userVO);
    }

    @PostMapping("/deleteById")
    public Map<String, Object> deleteById(@RequestParam Integer id) {
        return userService.deleteById(id);
    }

    @PostMapping("/updateById")
    public Map<String, Object> updateById(@RequestBody UserUpdateVO userUpdateVO) {
        return userService.updateById(userUpdateVO);
    }

    @PostMapping("/selectById")
    public Map<String, Object> selectById(@RequestParam Integer id) {
        // System.out.println("经过了一次基于ID的个人信息查询");
        return userService.selectById(id);
    }

//asUAHDHD
}
